﻿
using Microsoft.AspNetCore.Http;
using Models.Common;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using static Models.Common.EnumDeviceModelType;
using ServiceWeb.WebAdmin;
using Microsoft.AspNetCore.Mvc;
using UtilsORM;
using UtilsORM.MySqlData;
////using System.Web.Script.Serialization;

namespace ServiceWeb.DBGateway
{
    public class DBIotDeviceGateway
    {


        EFYihongIotContext ef = new EFYihongIotContext();
        public iot_device_gateway getGateway(string dguid)
        {
            return ef.iot_device_gateway.Where(c => c.gw_d_guid == dguid).FirstOrDefault();
        }

        public DataTable getGatewayDetail(string dguid)
        {
            string sql = "select * from iot_device_gateway where  gw_d_guid='" + dguid + "' ";
            DataTable dt = new MySqlYihongIot().Db.Ado.GetDataTable(sql);
            //if (dt.Rows.Count > 0)
            //{
            //    ViewData["cputemperature"] = dt.Rows[0]["gw_cpu_temperature"];
            //    ViewData["gputemperature"] = dt.Rows[0]["gw_gpu_temperature"];
            //    ViewData["memory_total"] = dt.Rows[0]["gw_memory_total"];
            //    ViewData["memory_use"] = dt.Rows[0]["gw_memory_use"];
            //    ViewData["gw_code"] = dt.Rows[0]["gw_code"];
            //    ViewData["gw_deviceid"] = dt.Rows[0]["gw_deviceid"];
            //    ViewData["system_code"] = dt.Rows[0]["gw_system_start_code"];
            //    ViewData["system_start_time"] = Convert.ToDateTime(dt.Rows[0]["gw_start_time"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
            //    ViewData["gw_live_time"] = Convert.ToDateTime(dt.Rows[0]["gw_live_time"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
            //}
            return dt;
        }
    }
}
